Overview

knitr::opts_chunk$set(echo = TRUE)

# Load libraries for homework problems
library(tidyverse)
library(gt)
library(patchwork)
# Read in COVID19 data
cv19 <- read_csv('data/usa_covid19.csv')

cv19

Problem 1

Create two new columns in cv19:

  • cases_new the number of new cases identified on a given day for a given state.

  • deaths_new the number of new deaths confirmed on a given day for a given state.

Notes:

  • the lag function is helpful for this.

  • Your solution should look like this

read_rds('solutions/01_solution.rds')

Problem 2

Compute the total number of new cases identified and deaths confirmed each day in the USA on or after March 1st, 2020. Your summarized data should look like this:

read_rds('solutions/02_solution.rds')

Problem 3

Using the data created in problem 2, create two bar plots showing the number of new cases identified and deaths confirmed in the USA after March 1st, 2020.

Notes This is a great chance to learn about the patchwork R package.

Your solution should look like this

read_rds('solutions/03_solution.rds')

Problem 4

Add four new columns to the data you created in problem 1:

  • cases_per100k: Number of cases per 100,000 citizens
  • deaths_per100k: Number of deaths per 100,000 citizens
  • cases_dbl_days: Number of days until case count doubles, based on current day’s case count
  • deaths_dbl_days: Number of days until death count doubles, based on current day’s death count.

Challenge yourself:

  • filter the data you have created in this problem to contain only the most recent day.

  • Identify the 10 states that have the highest death rate per 100,000 citizens.

  • Tabulate the total number, rate, and days to double for cases and deaths in each of these 10 states.

Your solution should look like this:

read_rds('solutions/04_solution.rds')
Cases Deaths
Total count Rate per 100k No. days to double Total count Rate per 100k No. days to double
New York 92,770 469 9.45 2,653 13.4 2.73
Louisiana 9,150 196 2.36 310 6.64 7.38
New Jersey 25,590 286 6.67 539 6.02 1.93
Michigan 10,791 109 6.20 417 4.20 4.15
Washington 6,585 91.8 5.60 300 4.18 4.88
Connecticut 3,824 106 13.3 112 3.12 3.15
Vermont 338 54.0 18.9 17.0 2.72 16.0
Massachusetts 8,966 132 6.30 154 2.27 3.81
District of Columbia 653 97.1 8.75 12.0 1.79 11.0
Colorado 3,728 68.3 8.76 96.0 1.76 5.00

Problem 5

Learn something new: take a look at a famous flipbook created by Gina Reynolds. The cv19 data have a very similar structure to that of the flipbook in Gina’s talk. Learn about the ggplot2 tools that are used in the flipbook and try to adapt them to create the ‘racing bar chart’ below.